<!doctype html>
<html>
  <head>
  <link rel="icon" 
      type="image/png" 
      href="favicon.png">
      <title>fasttimesheet - attendance</title>
  	<meta http-equiv="content-type" content=""text/htm; charset=UTF-8" >
	<link href="default.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="jquery/jquery.js"></script>
    
    
	<link href="jquery/jquery-ui.css" rel="stylesheet" type="text/css"/>
  	<script src="jquery/jquery-ui.min.js"></script>
  	
  	
 <link rel="stylesheet" href="jquery-ui-1.8.4.custom.css" type="text/css" />
<link rel="stylesheet" href="jquery/jquery.autocomplete.css" type="text/css" />
  <script type="text/javascript" src="jquery/jquery.bgiframe.min.js"></script>
  
  <script type="text/javascript" src="jquery/jquery.autocomplete.js"></script>  	
  	<script type="text/javascript" src="jquery/jquery.jeditable.js"></script>
  	
  	
  	
  
    <script type="text/javascript">
     
    </script>
  </head>
  <body>
  <style type="text/css">
	.ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; }
	</style>
<script>

function alerter() {
	alert("lol");	
	}
	
function totimesetter() {
	$.post("core/timesetter.php", { 
  			from: $("#from").val(),
  			duration: $("#duration").val(),
  			action: "to"
  			}, 
  			function(data){
   		$('#to').val(data);
   		
 			}); 
	}

function durationsetter() {
	$.post("core/timesetter.php", { 
  			from: $("#from").val(),
  			to: $("#to").val(),
  			action: "duration"
  			}, 
  			function(data){
   		$('#duration').val(data);
   		
 			}); 
	}

function timeinitializer() {
	
	$.post("visual/lasttasktime.php",function(data){
   		$('#from').val(data);
   		totimesetter();
 			}); 
	}


	
function validatetime_to(tim,id) {
	$.post("core/validatetime_to.php",{value: tim, id: id},function(data){
			//alert(data);   		
			$('#info').html(data);
			errordialog();
   		}); 
	}	

 function loadtasks() 
	{
	$.post("visual/taskcaller.php", function(data){
   $('#mainview').html(data);
   timeinitializer();
   $('.edit').editable('core/editnote.php',{style: "inherit"});
   $('.edittimefrom').editable('core/jobtimeeditor.php',{style: "inherit", callback : function(value, settings) {
		    
        loadtasks() ;
        //alert(this.id); 
        validatetime(value,this.id);	
         
	     }
     });
   $('.edittimeto').editable('core/jobtimeeditor_to.php',{style: "inherit",callback : function(value, settings) {
		    
        loadtasks() ;
        //alert(this.id); 
        validatetime_to(value,this.id);	
         
	     }
     });
 	});
	};


function setjobid() {
	$.post("core/getjobid.php",{ 
  					jobpath: $("#jobpicker").val()
  					},function(data) {
					$('#jobid').val(data);  			
  					});	
	};
	
function setjob(id) {
	$.post("core/returnpath.php",{ 
  			id: id
  			},function(data) {
			$('#thisjob').html(data);
			$("#jobpicker").val(data);
			$('#jobid').val(id);  			
  			});	
	}

function deletetask(id) {
		$.post("core/taskdeleter.php",{ 
  			id: id
  			}, 
  		function(data){
  			
   		loadtasks();
 			});
	}
	

	
//element visualisation functions
function treeaccordeon() {
	 $("#tree").accordion({
			collapsible: true,
			active: false,
			autoHeight: false
		});
	//$("#selectablejob").selectable();
	}

function selectanimate() {
	$(".hovertoggle").hover(function() {
		$(this).animate({ backgroundColor: "#68BFEF", opacity: 0.7 }, 100);
		});
	$(".hovertoggle").mouseleave(function() {
    		$(this).animate({ backgroundColor: "#b2aeae", opacity: 0.75 }, 100);
		});
	}
	
function errordialog() {
	if ($("#info").html() != "") {
	//alert ();
	$("#info").dialog({
			modal: true,
			minWidth: 400,
			buttons: {
				Ok: function() {
					$(this).dialog('close');
				}
			}
		});
	}
}


//---------------------------
function loadmonth(month) {
		$.post("visual/loadmonth.php",{ 
  			month: month,
  			year: $("#year").val()
  			}, 
  		function(data){
  		$("#month").html(data);	
  		attendance();
   		dayhover();
 			});
 	$("#monthholder").val(month);	
 	
	}
	
function loadmonthnumber() {
		$.post("visual/loadmonthnumber.php", 
  		function(data){
  		//alert(data);
  		$("#monthholder").val(data);
  		return data;
  		});
 		
 		
	}

function loadyearnumber() {
		$.post("visual/loadyearnumber.php", 
  		function(data){
  		$("#year").val(data);
  		return data;
  				});
 		
 		
	}

function initialize() {
	$.post("visual/loadmonthnumber.php", 
  		function(data){
  		//alert(data);
  		$("#monthholder").val(data);
  		$.post("visual/loadyearnumber.php", 
  			function(data){
  			$("#year").val(data);
  			loadmonth($("#monthholder").val());
  				});
  		});
	
	}
function validateattendance(time) {
	$.post("core/validate_attendance_format.php",{value: time},function(data){
			//alert(data);   		
			$('#info').html(data);
			errordialog();
			loadmonth($("#monthholder").val()); 
   		}); 
	}
	
function attendance() {
	$(".editattend").editable("visual/setattendance_specday.php", { 
	            placeholder: 'Edit',
	            submitdata : {year: $("#year").val() ,
	            		month: $("#monthholder").val() 
	            		},
	            		callback : function(value, settings) {
	            			//alert(value);
		   			validateattendance(value);
		   			
        				
         
	     				}
	            		
	            		
  			});
  	note();
 	
	}
	
function note() {
	$(".note").editable("visual/editnote_specday.php", { 
	            height: 30,
	            width: 90,
	            type: 'textarea',
	            submit: 'ok',
	            submitdata : {year: $("#year").val() ,
	            		month: $("#monthholder").val() 
	            		},
	            		callback : function(value, settings) {
	            			//alert(value);
		   			loadmonth($("#monthholder").val());
		   			
        				
         
	     				}
	            		
	            		
  			});
 	
	}

function workloadcomputer(month,day,year) {
	//alert(month);
	$.post("core/computeattend_speciffic.php",{ 
  			month: month,
  			year: year,
  			day: day
  			}, 
  		function(data){
  		//alert(data);
  		loadmonth(month);
  		attendance();
   		
 			});
}


$(document).ready(function(){
	attendance();
	initialize();
	
	});

function dayhover(){
$("td").hover(function() {
		//alert('lol');
  		$(this).addClass('lit');
  		//$(this).animate({ backgroundColor: "green", opacity: 0.85 }, 50);
		}, function() {
  		$(this).removeClass('lit');
		});
 }
  
//element visualisations

$(document).ready(function() {
  	$('#loadinfo').hide();
  });

 $(document).ready(function() {
  	$('#loadinfo').ajaxStart(function() {
  	$(this).show();
  	//$(this).text('Loading');
  	//$(this).removeClass('loaded');
  	//$(this).addClass('loading');
	});
	
	$('#loadinfo').ajaxStop(function() {
	$(this).hide(50);
  	//$(this).text('Loaded');
  	//$(this).removeClass('loading');
  	//$(this).addClass('loaded');
	});
  });
 
</script>

<div id="leftdiv" class="maindiv">
<?php 
$user=new core_user;
echo $loc->year  ?>: <select name="year" id="year" size="1"> 
<?php 
$years=explode("-",$year_range);
for ($j = $years[0]; $j <= $years[1]; $j++) {
	echo "<option value='".$j."'>".$j."";
	} 
	
?>
</select>
<h2><?php echo $loc->mnt  ?>:<h2>
<?php
for ($i=1;$i<=12;$i++) {
	echo "<h3><span class='month' onClick='loadmonth(\"".$i."\")'>".$loc->month[$i]."</span></h3>";
	
	}
?>
</div>

<div id="right">

<div class="maindiv" id="loginfo"><p class="vertcenter"><?php echo $loc->logged_user;?>: <b><?php echo $user->getUserName($_SESSION['uid']);?> </b>
<br>
<form id="logoutform" action="index.php" method="POST">
<input type="submit" name="logout" value="log out" >
</form>
</p>
</div>
<div class="separator"></div>
<div class="maindiv" id="menu" >
<form action="index.php" method="POST"><input type="hidden" name="switch" value="attend"><input type="hidden" value="attendance"></form>
<form action="index.php" method="POST"><input type="hidden" name="switch" value="main"><input type="hidden" value="tasks"></form>

<div class="maindiv" id="picker">
<form action="index.php" method="POST"><input type="submit" name="tasks" value="<? echo $loc->tasks_wiev; ?>"> <input type="hidden" name="switch" value="main"></form>

</div>

</div>


<div id="info"></div>
<div class="separator"></div>
<div class="maindiv" id="month" ></div>
<input type="hidden" id="monthholder" value="">


<?php
//echo date('m/d/Y');
require 'footer.php';
?>

</div>

<div class="loaded" id="loadinfo"><table><tr><td><img src="loading.gif" alt="loading"></td> <td><span id="loadtext"> Loading </span></td></tr></table></div>

<script>

</script>
</body>
</html>
